package com.example.jeong.yuejian10.Activity;



import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.example.jeong.yuejian10.Adapter.MyCollectMatchListAdapter;
import com.example.jeong.yuejian10.Bean.MatchBean;
import com.example.jeong.yuejian10.Listener.RetrofitListener;
import com.example.jeong.yuejian10.Model.UserModel;
import com.example.jeong.yuejian10.R;

import java.util.List;

//我的关注-比赛
public class MyCollectMatchActivity  extends Activity implements View.OnClickListener,RetrofitListener<List<MatchBean>> {
    private Button collectTrain_button,
            collectClub_button,
            collectMaster_button,
            collectAct_button;
    private ImageView left;

    private int u_id;
    private RecyclerView recyclerView;
    private MyCollectMatchListAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_collect_list);
        initView();
        initEvents();
        getMyCollectMatch();
    }
    private void initView(){
        collectTrain_button=(Button) findViewById(R.id.collectTrain_button);
        collectClub_button=(Button) findViewById(R.id.collectClub_button);
        collectMaster_button=(Button) findViewById(R.id.collectMaster_button);
        collectAct_button=(Button) findViewById(R.id.collectAct_button);
        left=(ImageView)findViewById(R.id.left);
        recyclerView=(RecyclerView) findViewById(R.id.my_collect);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));//设置布局


    }
    private void initEvents(){

        //返回上一页
        left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        //跳转到培训--当前activity
        collectTrain_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(MyCollectMatchActivity.this,MyCollectListActivity.class);
                startActivity(intent);
            }
        });

        //跳转到俱乐部
        collectClub_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(MyCollectMatchActivity.this,MyCollectClubActivity.class);
                startActivity(intent);
            }
        });

        //跳转到活动
        collectAct_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(MyCollectMatchActivity.this,MyCollectActActivity.class);
                startActivity(intent);
            }
        });

        //跳转到大师
        collectMaster_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(MyCollectMatchActivity.this,MyCollectMasterActivity.class);
                startActivity(intent);
            }
        });
    }
    void getMyCollectMatch(){
        SharedPreferences sp = getSharedPreferences("userInfo", Context.MODE_PRIVATE);
        u_id = sp.getInt("u_id", 0);
        UserModel userModel=new UserModel();
        userModel.getMyCollectMatch(u_id,"2",this);
    }

    @Override
    public void onSuccess(List<MatchBean> matchBean){
        adapter = new MyCollectMatchListAdapter(MyCollectMatchActivity.this,matchBean);
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void onFail() {
        //showToast("网络发生错误");
    }
    @Override
    public void onClick(View view) {

    }

}

